package com.hhc.appearance;

/**
 * 示例中，CPU、Memory、HardDrive 是构成计算机启动过程的子系统组件。
 * ComputerFacade 提供了一个简化的接口 startComputer()，它在内部协调这些子系统来启动计算机。
 * 客户端只需与 ComputerFacade 交互，无需了解计算机启动过程的底层复杂性。
 */
// 子系统组件
class CPU1 {
    void start() {
        System.out.println("CPU is starting...");
    }
}

class Memory1 {
    void load() {
        System.out.println("Memory is loading data...");
    }
}

class HardDrive1 {
    void readData() {
        System.out.println("Hard Drive is reading data...");
    }
}

// 外观
class ComputerFacade {
    private CPU1 cpu;
    private Memory1 memory;
    private HardDrive1 hardDrive;

    public ComputerFacade() {
        this.cpu = new CPU1();
        this.memory = new Memory1();
        this.hardDrive = new HardDrive1();
    }

    public void startComputer() {
        System.out.println("Starting computer...");
        cpu.start();
        memory.load();
        hardDrive.readData();
        System.out.println("Computer has started.");
    }
}

// 客户端
public class Main1 {
    public static void main(String[] args) {
        ComputerFacade computerFacade = new ComputerFacade();
        computerFacade.startComputer();
    }
}
